  type Person = {
    name: string;
    age: number;
    email: string;
  };
  
  type Mypick<T, K extends keyof T> = {
    [k in K]: T[k];
  };

  type testMyPick = Mypick<Person, "name" | "age">;
  
  type MyReadonly<T> = {
    readonly [k in keyof T]: T[k];
  };

  type testReadOnly = MyReadonly<Person>;


  // 获取联合类型
  type unionKey = keyof { name: string; age: number };
  
  // 一个 "name" | "age" | "email" 宽类型，无法继承（赋值）给一个窄类型"name"
  type Example1 = keyof Person extends "name" ? string : boolean;
  // 一个窄类型可以继承（赋值）一个宽类型
  type Example2 = "name" extends keyof Person ? string : boolean;


  type arr = ["a", "b", "c"];
  type testArr = arr extends ["a"] ? true : false;
  type testArr2 = arr extends ["a"] ? true : false;
  type testArr3 = arr extends ["a", "b", "c"] ? true : false;
  //结论：元组类型的数据类型具有唯一性。


  // 任何对象都继承至空对象
  type testObj = { name: string } extends {} ? true : false;

  
  //结果： type notNever = string | boolean;
  type notNever = string | never | boolean;
  
  // 但在泛型中，extends左侧如果是一个联合类型，
  // T将会是这个联合类型中的某一个具体类型，然后去匹配右侧类型，接着T变为这个联合类型的下一个具体类型，如此循环
  // 这种特性：在泛型中，联合类型的分布式特性；
  type MyExclude<T, U> = T extends U ? never : T;
  
  type testExclude = MyExclude<keyof Person, "email">;
  
  // mapped映射类型
  // type mapped<T> = { [key in T]: T[key] };

  // 重映射
  type MyOmit<T, K extends keyof T> = {
    [key in keyof T as key extends K ? never : K]: key extends K ? never : T[key];
  };

  type MyOmit2<T, K extends keyof T> = {
    [key in MyExclude<keyof T, K>]: key extends K ? never : T[key];
  };
  
  type testOmit = MyOmit<Person, "email">;


  // as const 语法；可以将字面量值转为元祖类型
  const user = ["ck", "18"] as const;


  // 通过[number]获取索引值
  type TupleToObject<T extends readonly any[]> = { [K in T[number]]: K };

  type testTupleToObj = TupleToObject<typeof user>;
  